package com.triz.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.triz.common.annotation.Log;
import com.triz.common.core.controller.BaseController;
import com.triz.common.core.domain.AjaxResult;
import com.triz.common.enums.BusinessType;
import com.triz.business.domain.ProjectSystem;
import com.triz.business.service.IProjectSystemService;
import com.triz.common.utils.poi.ExcelUtil;
import com.triz.common.core.page.TableDataInfo;

/**
 * 项目系统Controller
 * 
 * @author hlk
 * @date 2025-11-15
 */
@RestController
@RequestMapping("/business/projectSystem")
public class ProjectSystemController extends BaseController
{
    @Autowired
    private IProjectSystemService projectSystemService;

    /**
     * 查询项目系统列表
     */
//    @PreAuthorize("@ss.hasPermi('business:projectSystem:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectSystem projectSystem)
    {
        startPage();
        List<ProjectSystem> list = projectSystemService.selectProjectSystemList(projectSystem);
        return getDataTable(list);
    }

    /**
     * 导出项目系统列表
     */
//    @PreAuthorize("@ss.hasPermi('business:projectSystem:export')")
    @Log(title = "项目系统", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectSystem projectSystem)
    {
        List<ProjectSystem> list = projectSystemService.selectProjectSystemList(projectSystem);
        ExcelUtil<ProjectSystem> util = new ExcelUtil<ProjectSystem>(ProjectSystem.class);
        util.exportExcel(response, list, "项目系统数据");
    }

    /**
     * 获取项目系统详细信息
     */
//    @PreAuthorize("@ss.hasPermi('business:projectSystem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(projectSystemService.selectProjectSystemById(id));
    }

    /**
     * 新增项目系统
     */
//    @PreAuthorize("@ss.hasPermi('business:projectSystem:add')")
    @Log(title = "项目系统", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectSystem projectSystem)
    {
        projectSystem.setCreateBy(getUsername());
        return toAjax(projectSystemService.insertProjectSystem(projectSystem));
    }

    /**
     * 修改项目系统
     */
//    @PreAuthorize("@ss.hasPermi('business:projectSystem:edit')")
    @Log(title = "项目系统", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectSystem projectSystem)
    {
        projectSystem.setUpdateBy(getUsername());
        return toAjax(projectSystemService.updateProjectSystem(projectSystem));
    }

    /**
     * 删除项目系统
     */
//    @PreAuthorize("@ss.hasPermi('business:projectSystem:remove')")
    @Log(title = "项目系统", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(projectSystemService.deleteProjectSystemByIds(ids));
    }
}
